import type { FullModelInfo, ModelInfo, SupplierInfo } from '../type'

/**
 * 组装完整模型数据
 *
 * @param model 模型数据（数据库）
 * @param supplier 提供商数据
 * @returns
 */
export const turnFullModelInfo = (model: ModelInfo, supplier: SupplierInfo): FullModelInfo => {
  if (!model) {
    return null
  }
  return {
    id: model.id,
    key: model.key,
    type: model.type,
    supplier: supplier
      ? {
          id: supplier?.id,
          name: supplier?.name,
          isActive: !!supplier?.isActive,
        }
      : undefined,
    name: model.name,
    size: model.size,
    toolUse: !!model.toolUse,
    vision: !!model.vision,
    inUse: !!model.inUse,
  }
}
